package demo.java.parallelprogram.threadpool.executors;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;

import demo.java.parallelprogram.threadpool.MyThread;

public class Executors {

	public static void main1(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
		System.out.println("=====start:====="+sdf.format(new Date()));
		ExecutorService executorService=java.util.concurrent.Executors.newCachedThreadPool();
		for(int i=0;i<1000;i++){
			executorService.execute(new MyThread("testJDKTheadPool"+Integer.toString(i)));
		}
		System.out.println("=====end:====="+sdf.format(new Date()));
	}
	
	/**
	 * 取最优线程池的大小数量
	 * @param args
	 */
	public static void main(String[] args) {
		int count = Runtime.getRuntime().availableProcessors();
		System.out.println(count);
	}
}
